#include "stm32f10x.h"                  // Device header
uint16_t Count_sensor_count;

void CountSensor_Init(void)
{
  //开启外设时钟
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//开启io口时钟
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);//开启AFIO时钟
  //配置IO口
  GPIO_InitTypeDef GPIO_InitStructure;	
  GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;//上拉输入模式
  GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;//PB13
  GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;//设置翻转速度
  GPIO_Init(GPIOB,&GPIO_InitStructure);
  //配置中断线
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource13);
  //配置中断
  EXTI_InitTypeDef EXTI_InitStructure;
  EXTI_InitStructure.EXTI_Line=EXTI_Line13;//13号中断线
  EXTI_InitStructure.EXTI_LineCmd=ENABLE;//使能中断线
  EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;//中断模式
  EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;//下降沿
  EXTI_Init(&EXTI_InitStructure);
  //配置中断向量控制器
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断组为2，两位响应优先级，两位抢占优先级
  NVIC_InitTypeDef NVIC_InitStructure;
  NVIC_InitStructure.NVIC_IRQChannel=EXTI15_10_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;//抢占优先级
  NVIC_InitStructure.NVIC_IRQChannelSubPriority=1;//响应优先级
  NVIC_Init(&NVIC_InitStructure);

	
}


void EXTI15_10_IRQHandler(void)
{
   if( EXTI_GetFlagStatus( EXTI_Line13 )==SET )//检测几号中断线
   {
        //while ( GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13) == 1 );
	    //Count_sensor_count ++;
		
     EXTI_ClearFlag(EXTI_Line13);//清除中断标志位
   }

}





